﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _08WordInSentence
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = "We are living in a yellow submarine. We don't have anything else. Inside the submarine is very tight. So we are drinking all the day. We will move out of it in 5 days.";
            string findWord = "we";
            string[] sentences = str.Split('.');
            Console.WriteLine("We are looking for the sentences with the word \"{0}\"",findWord);
            Console.WriteLine("Separate sentences:");
            foreach (var item in sentences)
            {
                Console.WriteLine(item.Trim() + ".");
            }
            Console.WriteLine("********************************************************");
            Console.WriteLine("Sentences matching the criterium:");
            for (int i = 0; i < sentences.Length; i++)
            {
                if (sentences[i].ToLower().IndexOf(" " + findWord.ToLower() +" ") >= 0)
                {
                    Console.WriteLine(sentences[i].Trim() + ".");
                }
                else if (sentences[i].ToLower().IndexOf(findWord.ToLower() +" ") >= 0)
                {
                    Console.WriteLine(sentences[i].Trim() + ".");
                }
                else if (sentences[i].ToLower().IndexOf(" " + findWord.ToLower() + ".") >= 0)
                {
                    Console.WriteLine(sentences[i].Trim() + ".");
                }
                else if (sentences[i].ToLower().IndexOf(" " + findWord.ToLower() + "!") >= 0)
                {
                    Console.WriteLine(sentences[i].Trim() + ".");
                }
            }
        }
    }
}
